<%--
  Created by IntelliJ IDEA.
  User: Yang
  Date: 2021/11/22
  Time: 13:38
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>

<!DOCTYPE html>
<html>
<%@include file="common/devhead.jsp"%>
<body style="background-color:white" class="nav-md">
<div class="container body">
    <%--    class="container-fluid"--%>
    <div style="padding-right: 15px;
    padding-left: 259px;
    margin-right: auto;
    margin-left: auto;">
        <div class="row">
            <p><span style="font-size: 20px">手游&nbsp;审核列表<span class="glyphicon glyphicon-user"></span></span> 系统管理员-您可以通过搜索或者其他的筛选项对手游的信息进行审核操作</p>
        </div>
        <form action="${pageContext.request.contextPath}/appInfo/devappInfoList" method="post">
            <input type="hidden" value="1"  name="pageNum">
            <div class="row">
                <div class="col-md-4 form-group">
                    <label for="softwareName" style="margin-right: 20px">手游名称</label>
                    <input type="text" name="softwareName"  id="softwareName" placeholder="输入手游名称" value="${softwareName}">
                </div>
                <div class="col-md-4 col-sm-12 col-xs-12 form-group">
                    <label class="col-sm-3 control-label">手游状态</label>
                    <div class="col-sm-6">
                        <select class="form-control" id="status" name="status">
                            <option value="0">请选择</option>
                            <c:forEach items="${ddry2}" var="ddd">
                                <c:if test="${status==ddd.valueId}">
                                    <option value="${ddd.valueId}" selected="selected">${ddd.valueName}</option>
                                </c:if>
                                <c:if test="${status!=ddd.valueId}">
                                    <option value="${ddd.valueId}">${ddd.valueName}</option>
                                </c:if>

                            </c:forEach>
                        </select>
                    </div>
                </div>
                <div class="col-md-4 col-sm-12 col-xs-12 form-group">
                    <label class="col-sm-3 control-label">所属平台</label>
                    <div class="col-sm-6">
                        <select class="form-control" id="flatformId" name="flatformId">
                            <option value="0">请选择</option>
                            <c:forEach items="${ddry}" var="dd">
                                <c:if test="${flatformId==dd.valueId}">
                                    <option value="${dd.valueId}" selected="selected">${dd.valueName}</option>
                                </c:if>
                                <c:if test="${status!=dd.valueId}">
                                    <option value="${dd.valueId}">${dd.valueName}</option>
                                </c:if>

                            </c:forEach>
                        </select>
                    </div>
                </div>
                <div class="col-md-4 col-sm-12 col-xs-12 form-group">
                    <label class="col-sm-2 control-label">一级分类</label>
                    <div class="col-sm-6">
                        <input type="hidden" id="level1" value="${categoryLevel1}">
                        <select class="form-control" name="categoryLevel1" id="categoryLevel1">
                            <option value='0'>请选择</option>
                            <c:if test="${categoryLevel1v==1}"><option value="1" selected="selected">全部游戏</option></c:if>
                            <c:if test="${categoryLevel1v!=1}"><option value="1" >全部游戏</option></c:if>

                        </select>
                    </div>
                </div>
                <div class="col-md-4 col-sm-12 col-xs-12 form-group">
                    <label class="col-sm-3 control-label">二级分类</label>
                    <div class="col-sm-6">
                        <input type="hidden" id="level2" value="${categoryLevel2}">
                        <select class="form-control" name="categoryLevel2" id="categoryLevel2">
                        </select>
                    </div>
                </div>
                <div class="col-md-4 col-sm-12 col-xs-12 form-group">
                    <label class="col-sm-3 control-label">三级分类</label>
                    <div class="col-sm-6">
                        <input type="hidden" id="level3" value="${categoryLevel3}">
                        <select class="form-control" name="categoryLevel3" id="categoryLevel3">
                        </select>
                    </div>
                </div>
                <div class="col-xs-6 col-sm-4">
                    <button type="submit" class="btn btn-primary btn-sm" id="sub">查询</button>
                </div>
            </div>
        </form>
        <div class="row">
            <!-- Button trigger modal -->
           <%-- <a class="btn btn-primary btn-lg" href="${pageContext.request.contextPath}/appInfo/toadd"> 新增APP信息</a>--%>
            <button type="button" class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal">
                新增APP信息
            </button>
            <!-- Modal -->
            <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
                <div class="modal-dialog" role="document">
                    <div class="modal-content">
                        <div class="modal-body" style="padding: 0px">
                            <div class="x_content" style="margin-top: 20px">
                                <form class="form-horizontal form-label-left" onsubmit="return tj();" enctype="multipart/form-data" method="post" action="${pageContext.request.contextPath}/appInfo/appInfoAdd">
                                    <div class="item form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="softwareName">手游名称 <span class="required">*</span>
                                        </label>
                                        <div class="col-md-6 col-sm-6 col-xs-12">
                                            <input  class="form-control col-md-7 col-xs-12" data-validate-length-range="6" data-validate-words="2" id="name" name="softwareName"  placeholder="请输入手游名称" type="text">
                                            <span></span>
                                        </div>
                                    </div>
                                    <div class="item form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="APKName">APK名称 <span class="required">*</span>
                                        </label>
                                        <div class="col-md-6 col-sm-6 col-xs-12">
                                            <input id="APKName" class="form-control col-md-7 col-xs-12" data-validate-length-range="6" data-validate-words="2" name="APKName" placeholder="请输入APK名称" type="text">
                                            <span class="apknameExist"></span>
                                            <input type="hidden" name="version" value="1"/>
                                        </div>
                                    </div>
                                    <div class="item form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="supportRom">支持ROM <span class="required">*</span>
                                        </label>
                                        <div class="col-md-6 col-sm-6 col-xs-12">
                                            <input id="supportROM" class="form-control col-md-7 col-xs-12" data-validate-length-range="6" data-validate-words="2"  name="supportROM" placeholder="请输入APK名称" type="text">
                                            <span></span>
                                        </div>
                                    </div>
                                    <div class="item form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="interfaceLanguage">界面语言 <span class="required">*</span>
                                        </label>
                                        <div class="col-md-6 col-sm-6 col-xs-12">
                                            <input id="interfaceLanguage" class="form-control col-md-7 col-xs-12" data-validate-length-range="6" data-validate-words="2" name="interfaceLanguage" placeholder="请输入手游支持的界面语言" type="text">
                                            <span></span>
                                        </div>
                                    </div>
                                    <div class="item form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="softwareSize">手游大小 <span class="required">*</span>
                                        </label>
                                        <div class="col-md-6 col-sm-6 col-xs-12">
                                            <input id="softwareSize" class="form-control col-md-7 col-xs-12" data-validate-length-range="6" data-validate-words="2" name="softwareSize" placeholder="请输入手游大小、单位为Mb" type="text">
                                            <span></span>
                                        </div>
                                    </div>
                                    <div class="item form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="downloads">下载次数 <span class="required">*</span>
                                        </label>
                                        <div class="col-md-6 col-sm-6 col-xs-12">
                                            <input id="downloads" class="form-control col-md-7 col-xs-12" data-validate-length-range="6" data-validate-words="2" name="downloads" placeholder="请输入下载次数" type="text">
                                            <span></span>
                                        </div>
                                    </div>
                                    <div class="item form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="flatformId">所属平台 <span class="required">*</span>
                                        </label>
                                        <div class="col-md-6 col-sm-6 col-xs-12">
                                            <select class="form-control"  name="flatformId" id="pt">
                                                <option value="0">请选择</option>
                                                <c:forEach items="${ddry}" var="dd">
                                                    <option value="${dd.valueId}">${dd.valueName}</option>
                                                </c:forEach>
                                            </select>
                                            <span></span>
                                        </div>
                                    </div>
                                    <div class="item form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="Levell1">一级分类 <span class="required">*</span>
                                        </label>
                                        <div class="col-md-6 col-sm-6 col-xs-12">
                                            <select class="form-control" name="categoryLevel1" id="levell1"></select>
                                            <span></span>
                                        </div>
                                    </div>
                                    <div class="item form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="levell2">二级分类 <span class="required">*</span>
                                        </label>
                                        <div class="col-md-6 col-sm-6 col-xs-12">
                                            <select class="form-control" name="categoryLevel2" id="levell2" ></select>
                                            <span></span>
                                        </div>
                                    </div>
                                    <div class="item form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="levell3">三级分类 <span class="required">*</span>
                                        </label>
                                        <div class="col-md-6 col-sm-6 col-xs-12">
                                            <select class="form-control" name="categoryLevel3" id="levell3" ></select>
                                            <span></span>
                                        </div>
                                    </div>
                                    <div id="fl"></div>
                                    <div class="item form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="status">手游状态 <span class="required">*</span>
                                        </label>
                                        <div class="col-md-6 col-sm-6 col-xs-12">
                                            <span>待审核</span>
                                            <input type="hidden" value="1" name="status"/>
                                        </div>
                                    </div>
                                    <div class="item form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="appInfo">应用简介 <span class="required">*</span>
                                        </label>
                                        <div class="col-md-6 col-sm-6 col-xs-12">
                                           <textarea id="appInfo" class="form-control col-md-7 col-xs-12" data-validate-length-range="6" data-validate-words="2" name="appInfo" placeholder="请输入本手游的相关性信息，本信息作为手游的详细介绍" type="text"></textarea>
                                            <span></span>
                                        </div>
                                    </div>
                                    <div class="item form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12">LOGO图片 <span class="required">*</span>
                                        </label>
                                        <div class="col-md-6 col-sm-6 col-xs-12">
                                            <input type="hidden" id="errorinfo" value="${uploadError}">
                                            <input type="file" class="form-control col-md-7 col-xs-12" data-validate-length-range="6" data-validate-words="2" name="picPath" id="picPath"/>
                                            <span></span>
                                        </div>
                                    </div>
                                    <div class="ln_solid"></div>
                                    <div class="form-group">
                                        <div class="col-md-6 col-md-offset-3">
                                            <button id="send"  type="submit" class="btn btn-success">保存</button>
                                            <a href="${pageContext.request.contextPath}/appInfo/devlist" class="btn btn-primary">返回</a>
                                        </div>
                                    </div>
                                </form>
                            </div>
                        </div>
                        <div class="modal-footer">

                        </div>
                    </div>
                </div>
        </div>
        <div class="row">
            <table class="table table-bordered">
                <tr>
                    <td>手游名称</td>
                    <td>APK名称</td>
                    <td>所属平台</td>
                    <td>所属分类(一级分类、二级分类、三级分类)</td>
                    <td>状态</td>
                    <td>软件大小(单位:M)</td>
                    <td>下载次数</td>
                    <td>最新版本号</td>
                    <td>操作</td>
                </tr>
                <c:forEach items="${appInfo}" var="app">
                    <tr>
                        <td>${app.softwareName}</td>
                        <td>${app.APKName}</td>
                        <td>${app.flatformname}</td>
                        <td>${app.categoryLevel1Name}>${app.categoryLevel2Name}>${app.categoryLevel3Name}</td>
                        <td>${app.statusname}</td>
                        <td>${app.softwareSize}</td>
                        <td>${app.downloads}</td>
                        <td>${app.versionname}</td>
                        <td><div class="btn-group">
                            <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" style="background-color: red">
                                点击操作<span class="caret"></span>
                            </button>
                            <c:if test="${app.statusname=='已上架'}">
                                <ul class="dropdown-menu">
                                    <input type="hidden" class="versionId"/>
                                    <li><a href="${pageContext.request.contextPath}/appInfo/xj/${app.id}">下架</a></li>
                                    <li><a href="${pageContext.request.contextPath}/appInfo/toversion/${app.id}">新增版本</a></li>
                                    <c:if test="${app.versionId==null}">
                                        <li><a href="javascript:;">修改版本</a></li>
                                    </c:if>
                                    <c:if test="${app.versionId!=null}">
                                        <li><a href="${pageContext.request.contextPath}/appInfo/toupVer/${app.id}/${app.versionId}/${app.downloads}">修改版本</a></li>
                                    </c:if>
                                    <c:if test="${app.status==1||app.status==3}">
                                        <li><a href="${pageContext.request.contextPath}/appInfo/view/${app.id}">修改</a></li>
                                    </c:if>
                                    <c:if test="${app.status!=1||app.status!=3}">
                                        <li></li>
                                    </c:if>
                                    <li><a href="${pageContext.request.contextPath}/appInfo/devView/${app.id}">查看</a></li>
                                    <li><a href="${pageContext.request.contextPath}/appInfo/devDel/${app.id}">删除</a></li>
                                </ul>
                            </c:if>
                            <c:if test="${app.statusname=='已下架' || app.statusname=='审核通过'}">
                                <input type="hidden" class="versionId"/>
                                <ul class="dropdown-menu">
                                    <li><a href="${pageContext.request.contextPath}/appInfo/sj/${app.id}">上架</a></li>
                                    <li> <a href="${pageContext.request.contextPath}/appInfo/toversion/${app.id}">新增版本</a></li>
                                    <c:if test="${app.versionId==null}">
                                        <li><a href="javascript:;">修改版本</a></li>
                                    </c:if>
                                    <c:if test="${app.versionId!=null}">
                                        <li><a href="${pageContext.request.contextPath}/appInfo/toupVer/${app.id}/${app.versionId}/${app.downloads}">修改版本</a></li>
                                    </c:if>
                                    <c:if test="${app.status==1||app.status==3}">
                                        <li><a href="${pageContext.request.contextPath}/appInfo/view/${app.id}">修改</a></li>
                                    </c:if>
                                    <c:if test="${app.status!=1||app.status!=3}">
                                        <li></li>
                                    </c:if>
                                    <li><a href="${pageContext.request.contextPath}/appInfo/devView/${app.id}">查看</a></li>
                                    <li><a href="${pageContext.request.contextPath}/appInfo/devDel/${app.id}">删除</a></li>
                                </ul>
                            </c:if>
                            <c:if test="${app.statusname!='已下架'&&app.statusname!='已上架'&&app.statusname!='审核通过'}">
                                <ul class="dropdown-menu">
                                    <input type="hidden" class="versionId"/>
                                    <li><a href="${pageContext.request.contextPath}/appInfo/toversion/${app.id}">新增版本</a></li>
                                    <c:if test="${app.versionId==null}">
                                        <li><a href="javascript:;">修改版本</a></li>
                                    </c:if>
                                    <c:if test="${app.versionId!=null}">
                                        <li><a href="${pageContext.request.contextPath}/appInfo/toupVer/${app.id}/${app.versionId}/${app.downloads}">修改版本</a></li>
                                    </c:if>
                                    <c:if test="${app.status==1||app.status==3}">
                                        <li><a href="${pageContext.request.contextPath}/appInfo/view/${app.id}">修改</a></li>
                                    </c:if>
                                    <c:if test="${app.status!=1||app.status!=3}">
                                        <li></li>
                                    </c:if>
                                    <li><a href="${pageContext.request.contextPath}/appInfo/devView/${app.id}">查看</a></li>
                                    <li><a href="${pageContext.request.contextPath}/appInfo/devDel/${app.id}">删除</a></li>
                                </ul>
                            </c:if>
                        </div></td>
                    </tr>
                </c:forEach>
            </table>
            <div class="row" style="margin-right: auto">
                <span> 共${pageInfo.total}记录&nbsp;${pageIndex}/${pageInfo.pages}</span>


                    <nav aria-label="...">
                        <ul class="pager">
                            <c:if test="${pageIndex>1}">
                            <li><a href="${pageContext.request.contextPath}/appInfo/devappInfoList?pageNum=1" >首页</a>&nbsp;&nbsp;</li>
                            <li><a href="${pageContext.request.contextPath}/appInfo/devappInfoList?pageN6um=${pageIndex-1}" >上一页</a>&nbsp;&nbsp;</li>
                            </c:if>
                            <c:if test="${pageIndex<pageInfo.pages}">
                                <li><a href="${pageContext.request.contextPath}/appInfo/devappInfoList?pageNum=${pageIndex+1}" >下一页</a>&nbsp;&nbsp;</li>
                                <li><a href="${pageContext.request.contextPath}/appInfo/devappInfoList?pageNum=${pageInfo.pages}" >最后一页</a></li>
                            </c:if>
                        </ul>
                    </nav>
            </div>
        </div>
    </div>
</div>
</body>
<%@include file="common/devfoot.jsp"%>
<script src="${pageContext.request.contextPath}/statics/js/jquery-1.12.4.js"></script>
<script src="${pageContext.request.contextPath}/statics/js/add.js"></script>
<script>
  /*  function sj(id){
        $.getJSON("${pageContext.request.contextPath}/appInfo/sj/"+id,"",function (data){
            if (data.status=="true"){
                $(this).parents("td").remove().attr()
            }
        })
    }*/

    /*function  del(id,name){
        var obj=this;
        var falg=confirm("你确定要删除APP应用【"+name+"】及其所有的版本吗？")
        if (falg){
            $.getJSON("${pageContext.request.contextPath}/appInfo/devDel/"+id,"",function (data){
                if (data==true){
                    $(obj).parents("tr").remove();
                }else {
                    alert("删除失败!");
                }
            })
        }
    }*/

    var option=null
    var path='${pageContext.request.contextPath}';
    $("#APKName").blur(function (){
        $.getJSON(path+"/appInfo/APKNameExist","APKName="+$("#APKName").val(),function (data){
            if (data.APKName=="true"){
                $(".apknameExist").html("");
            }else {
                $(".apknameExist").html("该APK名称已存在");
            }
        })
    })
    var backBtn=null;
    $(function () {
        backBtn = $("#back");
        backBtn.on("click",function(){
            //alert("view : "+referer);
            if(referer != undefined
                && null != referer
                && "" != referer
                && "null" != referer
                && referer.length > 4){
                window.location.href = referer;
            }else{
                history.back(-1);
            }
        });
      /*  $.getJSON(path+"/category/fenlei1",'',function (data){
            option="<option value='0'>请选择</option>";
            for (var i = 0; i < data.length; i++) {
                if($("#level1").val()==data[i].id){
                    option+="<option selected value='"+data[i].id+"'>"+data[i].categoryName+"</option>"
                }else {
                    option+="<option value='"+data[i].id+"'>"+data[i].categoryName+"</option>"
                }
            }
            $("#categoryLevel1").html(option);
        })*/
        $.ajax({
            type: "GET",
            url:path+"/category/fenlei2",
            data:{parentId:$("#level1").val()},
            dataType:"json",
            success:function (data){
                option="<option value='0'>请选择</option>";
                for (var i = 0; i < data.length; i++) {
                    if($("#level2").val()==data[i].id){
                        option+="<option selected='selected' value='"+data[i].id+"'>"+data[i].categoryName+"</option>"
                    }else{
                        option+="<option value='"+data[i].id+"'>"+data[i].categoryName+"</option>"
                    }
                }
                $("#categoryLevel2").html(option);
            }
        })
        $.getJSON(path+"/category/fenlei3",{parentId:$("#level2").val()},function (data){
            for (var i = 0; i < data.length; i++) {
                if($("#level3").val()==data[i].id){
                    option+="<option selected='selected' value='"+data[i].id+"'>"+data[i].categoryName+"</option>"
                }else {
                    option+="<option value='"+data[i].id+"'>"+data[i].categoryName+"</option>"
                }
            }
            $("#categoryLevel3").html(option);
        })

        $.getJSON(path+"/category/fenlei1",'',function (data){
            option="<option value='0'>请选择</option>";
            for (var i = 0; i < data.length; i++) {
                option+="<option value='"+data[i].id+"'>"+data[i].categoryName+"</option>"
            }
            $("#levell1").html(option);
        })

        $("#categoryLevel1").change(function (){
            var categoryLevel1=$("#categoryLevel1").val();
            if(categoryLevel1!="" && categoryLevel1!=null){
                $.ajax({
                    type: "GET",
                    url:path+"/category/fenlei2",
                    data:{parentId:categoryLevel1},
                    dataType:"json",
                    success:function (data){
                        option="<option value='0'>请选择</option>";
                        for (var i = 0; i < data.length; i++) {
                            option+="<option value='"+data[i].id+"'>"+data[i].categoryName+"</option>"
                        }
                        $("#categoryLevel2").html(option);

                    },
                    error:function (data){
                        alert("加载二级菜单失败")
                    }
                })
            }else{
                $("#categoryLevel2").html("");

                option="<option value='0'>请选择</option>";
                $("#categoryLevel2").html(option);

            }
            $("#categoryLevel3").html("");

            option="<option value='0'>请选择</option>";
            $("#categoryLevel3").html(option);

        })
        $("#categoryLevel2").change(function (){
            var categoryLevel2=$("#categoryLevel2").val();
            if(categoryLevel2!="" && categoryLevel2!=null) {
                $.ajax({
                    type: "GET",
                    url: path+"/category/fenlei3",
                    data: {parentId: categoryLevel2},
                    dataType: "json",
                    success: function (data) {
                        option = "<option value='0'>请选择</option>";
                        for (var i = 0; i < data.length; i++) {
                            option += "<option value='" + data[i].id + "'>" + data[i].categoryName + "</option>"
                        }

                        $("#categoryLevel3").html(option);
                    },
                    error:function (data){
                        alert("加载三级菜单失败")
                    }
                })
            }
        })
        $("#levell1").change(function (){
            var categoryLevel1=$("#levell1").val();
            if(categoryLevel1!="" && categoryLevel1!=null){
                $.ajax({
                    type: "GET",
                    url:path+"/category/fenlei2",
                    data:{parentId:categoryLevel1},
                    dataType:"json",
                    success:function (data){
                        option="<option value='0'>请选择</option>";
                        for (var i = 0; i < data.length; i++) {
                            option+="<option value='"+data[i].id+"'>"+data[i].categoryName+"</option>"
                        }
                        $("#levell2").html(option);
                    },
                    error:function (data){
                        alert("加载二级菜单失败")
                    }
                })
            }else{

                $("#levell2").html("");
                option="<option value='0'>请选择</option>";

                $("#levell2").html(option);
            }

            $("#levell3").html("");
            option="<option value='0'>请选择</option>";

            $("#levell3").html(option);
        })
        $("#levell2").change(function (){
            var categoryLevel2=$("#levell2").val();
            if(categoryLevel2!="" && categoryLevel2!=null) {
                $.ajax({
                    type: "GET",
                    url: path+"/category/fenlei3",
                    data: {parentId: categoryLevel2},
                    dataType: "json",
                    success: function (data) {
                        option = "<option value='0'>请选择</option>";
                        for (var i = 0; i < data.length; i++) {
                            option += "<option value='" + data[i].id + "'>" + data[i].categoryName + "</option>"
                        }
                        $("#levell3").html(option);

                    },
                    error:function (data){
                        alert("加载三级菜单失败")
                    }
                })
            }
        })
    })
</script>
</html>
